import { Divider, Space, Table, Tag } from 'antd';
import React, { useEffect, useState } from 'react';
import { userList } from "../../http/request";
import moment from "moment";


const App = () => {
    const [data, setData] = useState([])
    useEffect(() => {
        userList().then(res => {
            // console.log(res.data.data);
            setData(() => res.data.data)
        })
    }, [])

    //标题
    const columns = [
        {
            title: '序号',
            render: (text, item, index) => <span>{index + 1}</span>,
        },
        {
            title: "昵称",
            dataIndex: "nickname"
        },
        {
            title: "性别",
            dataIndex: "sex",
            render: (text) => <span>{text == -1 ? "男" : "女"}</span>
        },
        {
            title: "电话",
            dataIndex: "tel"
        },
        {
            title: "创建日期",
            dataIndex: "createTime",
            render: (text) => <span>{text ? moment(text * 1).format("YYYY-MM-DD HH:mm:ss") : "未注册"}</span>
        }
    ];


    return (
        <div>
            <Table columns={columns} dataSource={data} rowKey={render => render.userid} scroll={{
                y: 500,
            }} />
        </div>
    )
}

export default App;